﻿@model IEnumerable<handvn.Models.User>
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@if (Request.IsAuthenticated && @Session["LoaiTaiKhoan"]!=null)
{
    if( @Session["LoaiTaiKhoan"].ToString() == "admin")
    {
    <h1>
        Quản lý người dùng</h1>
    <h2>
        Index</h2>
    <p>
        @Html.ActionLink("Create New", "Create")
    </p>
    <table>
        <tr>
            <th>
                Username
            </th>
            <th>
                Password1
            </th>
            @*<th>
            Password2
        </th>*@
            <th>
                TenKhachhang
            </th>
            <th>
                CMND
            </th>
            <th>
                DienThoai
            </th>
            <th>
                Email
            </th>
            <th>
                DiaChi
            </th>
            <th>
                NgayDangKy
            </th>
            <th>
                HinhAnh
            </th>
            <th>
                CategoriesUser
            </th>
            <th>
                TinhTrang
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Username)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Password1)
                </td>
                @*<td>
            @Html.DisplayFor(modelItem => item.Password2)
        </td>*@
                <td>
                    @Html.DisplayFor(modelItem => item.TenKhachhang)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CMND)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DienThoai)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Email)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DiaChi)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.NgayDangKy)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.HinhAnh)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.CategoriesUser.TenLoaiNguoiDung)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TinhTrang)
                </td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { id = item.UserID }) |
                    @Html.ActionLink("Details", "Details", new { id = item.UserID }) |
                    @Html.ActionLink("Delete", "Delete", new { id = item.UserID })
                </td>
            </tr>
        }
    </table>
    }
}
else
{
    <p>
        Xin vui lòng đăng nhập</p>
    <script type="text/javascript">
        window.location.href = "http://localhost:5286/account/admin"
    </script>
}